package by.amakarevich.services.impl;

import javax.inject.Inject;

import org.springframework.stereotype.Service;

import by.amakarevich.dataaccess.GoodToKnowDao;
import by.amakarevich.datamodel.GoodToKnow;
import by.amakarevich.services.GoodToKnowService;

@Service
public class GoodToKnowServiceImpl implements GoodToKnowService {
	@Inject
	private GoodToKnowDao goodToKnowDao;

	@Override
	public GoodToKnow get(Long id) {
		GoodToKnow entity = goodToKnowDao.getById(id);
		return entity;
	}

	@Override
	public void saveOrUpdateGoodToKnow(GoodToKnow goodToKnow) {
		if (goodToKnow.getId() == null) {
			goodToKnowDao.insert(goodToKnow);
		} else {
			goodToKnowDao.update(goodToKnow);
		}
	}

	@Override
	public void deleteGoodToKnow(GoodToKnow goodToKnow) {

		goodToKnowDao.delete(goodToKnow.getId());

	}

	@Override
	public void deleteAll() {
		goodToKnowDao.deleteAll();
	}
}
